package com.leo.util;

import java.io.IOException;

import com.leo.entity.Student;
import com.leo.vo.NetBugResult;

/**
 * 教务爬虫损坏，新建桩模块维持开发
 * @author clown_leo
 *
 */
public class JiaowuNetBugStub implements JiaowuNetBug {

	@Override
	public NetBugResult checkPassword(String stuID ,String password) {
		return login(stuID, password, null);
	}

	/* (non-Javadoc)
	 * @see com.leo.util.JiaowuNetBug#logOut()
	 */
	@Override
	public void logOut() throws IOException{
	}

	/**
	 * @param page 登录成功后请求的页面，如学生个人信息是"xsgrxx.apsx"
	 * 
	 */
	private NetBugResult login(String stuID ,String password, String page) {
		//输入的账号密码非空
		if (stuID == null || password == null || stuID == "" || password == "") {
			return NetBugResult.stuIDOrPasswordError();
		}
		return new NetBugResult("1","");
	}

	/* (non-Javadoc)
	 * @see com.leo.util.JiaowuNetBug#getInfo(java.lang.String, java.lang.String)
	 */
	@Override
	public NetBugResult getInfo(String stuID ,String stuPassword) {

		try {
			//输入的账号密码非空
			if(stuID == null || stuPassword == null) {
				return NetBugResult.stuIDOrPasswordError();
			}

			Student student = new Student();
			//学生班
			student.setClassName("class");
			//学院
			student.setCollege("college");
			//入学日期
			student.setEntranceDate("entrance");
			//当前所在级
			student.setGrade("grade");
			//学号
			student.setStuID(stuID);
			//密码
			student.setPassword(stuPassword);
			//姓名
			student.setName("name");
			//电话
			student.setPhone("phone");
			//专业名称
			student.setProfessional("professiona");
			//性别
			student.setSex("sex");
			//数据版本
			student.setVersionTime(Student.nowVersionTime());

			return new NetBugResult("1", student);

		} catch (NullPointerException e) {
			return NetBugResult.networkError();
		}
	}

	@Override
	public NetBugResult getScore(String stuID, String stuPassword) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean validateAccount(String stuID, String password) {
		// TODO Auto-generated method stub
		return true;
	}
}